import { onBeforeUnmount, onMounted, reactive } from 'vue'

export default function () {
  const point = reactive({
    x: 0,
    y: 0
  })

  function movePoint(e) {
    point.x = e.pageX
    point.y = e.pageY
  }

  onMounted(() => {
    document.addEventListener('click', movePoint)
  })

  onBeforeUnmount(() => {
    document.removeEventListener('click', movePoint)
  })


  return point
}